import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * This is an extended employee class for a globally distributed software development
 * environment.Some features like time-zone,culture,language have been add in this 
 * class.
 * 
 * @author zhongnanhai
 *
 */
public class Employee{
	private static final long serialVersionUID = 1L;
	/**employee name*/
	private String employeename;
	/**employee description*/
	private String employeedescription;
	/** The time-zone of an employee.*/
	private int timeZone;
	/** his country*/
	private int country;
	/**Is this employee is available or not*/
	private boolean available = true;
	/**The employee's salary*/
	private int salary;
	/**The skill and corresponding productivity this employee owns.*/
	private Map<Integer,Float> productivity = new HashMap<Integer,Float>();
	/**The roles this employee has.*/
	private ArrayList<Integer> roles = new ArrayList<Integer>();
	
	/**
	 * Get a single simple string format of the skill and its productivity
	 * @return concatenated (skill,productivity) string
	 */
	public String getProductivityString(){
		String pdStr = "";
		if(productivity.size()>0){
			for(Integer key : productivity.keySet()){
				float value =  productivity.get(key);
				pdStr += "("+AllBasicData.skills[key]+","+value+")"+",";
			}
		}
		return unget(pdStr);
	}
	/**
	 * Remove the last comma if necessary
	 * @param str string created by get***String() function
	 * @return string with better format
	 */
	private String unget(String str){
		if(str.isEmpty()) return str;
		else{
			return str.substring(0, str.length()-1);
		}
	}
	/**
	 * Get a single simple string format of the roles
	 * @return concatenated role string
	 */
	public String getRoleString(){
		String roleStr = "";
		if(roles.size() > 0){
			for(Integer index:roles)
			roleStr += AllBasicData.roles[index] + ",";
		}
		return unget(roleStr);
	}
	
	public boolean isAvailable() {
		return available;
	}
	public void setAvailable(boolean available) {
		this.available = available;
	}
	public int getTimeZone() {
		return timeZone;
	}
	public void setTimeZone(int timeZone) {
		this.timeZone = timeZone;
	}
	public int getCountry() {
		return country;
	}
	public void setCountry(int country) {
		this.country = country;
	}
	public int getSalary() {
		return salary;
	}
	public void setSalary(int salary) {
		this.salary = salary;
	}
	public Map<Integer, Float> getProductivity() {
		return productivity;
	}
	public void setProductivity(Map<Integer, Float> productivity) {
		this.productivity = productivity;
	}
	public ArrayList<Integer> getRoles() {
		return roles;
	}
	public void setRoles(ArrayList<Integer> roles) {
		this.roles = roles;
	}
	public String getemployeename() {
		return employeename;
	}
	public void setemployeename(String employeename) {
		this.employeename = employeename;
	}
	public String getemployeedescription() {
		return employeedescription;
	}
	public void setemployeedescription(String employeedescription) {
		this.employeedescription = employeedescription;
	} 
}
